package org.cb.core;

import java.awt.Canvas;
import java.awt.Rectangle;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.util.Random;

import org.cb.input.Keyboard;
import org.cb.input.Mouse;

/**
 * 
 * @author Unknown
 * 
 * Global variables.
 *
 */
public class Global {
	private static double version = 1.00;
	
	private static boolean shouldPaint = true;
	private static boolean allowMouse = true;
	private static boolean paintMouse = true;
	private static boolean readyToGetColour = false;
	private static boolean loaded = false;
	private static boolean scriptRunning = false;
	
	private static Canvas theCanvas;
	private static MouseMotionListener mouseMovement;
	
	private static Mouse theMouse;
	private static Keyboard theKeyboard;
	
	private static BufferedImage mouseIcon;
	
	private static Listener listen;
	
	private static int mainGUIx;
	private static int mainGUIy;
	private static int rs_panex;
	private static int rs_paney;
	
	private static Rectangle screenArea;
	private static Rectangle playArea;
	private static Rectangle minimapArea;
	private static Rectangle tabArea;
	private static Rectangle chatArea;
	
	private static Random random = new Random();

	public static double getVersion() {
		return version;
	}

	public static boolean isShouldPaint() {
		return shouldPaint;
	}

	public static boolean isAllowMouse() {
		return allowMouse;
	}

	public static boolean isLoaded() {
		return loaded;
	}

	public static Canvas getTheCanvas() {
		return theCanvas;
	}

	public static void setVersion(double version) {
		Global.version = version;
	}

	public static void setShouldPaint(boolean shouldPaint) {
		if(shouldPaint)
			theCanvas.setPaintOn();
		else
			theCanvas.setPaintOff();
			
		Global.shouldPaint = shouldPaint;
	}

	public static void setAllowMouse(boolean allowMouse) {
		if(allowMouse){
			theCanvas.addMouseMotionListener(mouseMovement);
		}else{
			mouseMovement = theCanvas.getMouseMotionListeners()[0];
			theCanvas.removeMouseMotionListener(theCanvas.getMouseMotionListeners()[0]);
		}
		
		Global.allowMouse = allowMouse;
	}

	public static void setLoaded(boolean loaded) {
		Global.loaded = loaded;
	}

	public static void setTheCanvas(Canvas theCanvas) {
		Global.theCanvas = theCanvas;
	}

	public static MouseMotionListener getMouseMovement() {
		return mouseMovement;
	}

	public static void setMouseMovement(MouseMotionListener mouseMovement) {
		Global.mouseMovement = mouseMovement;
	}

	public static boolean isScriptRunning() {
		return scriptRunning;
	}

	public static void setScriptRunning(boolean scriptRunning) {
		Global.scriptRunning = scriptRunning;
	}

	public static Mouse getTheMouse() {
		return theMouse;
	}

	public static Keyboard getTheKeyboard() {
		return theKeyboard;
	}

	public static void setTheMouse(Mouse theMouse) {
		Global.theMouse = theMouse;
	}

	public static void setTheKeyboard(Keyboard theKeyboard) {
		Global.theKeyboard = theKeyboard;
	}

	public static BufferedImage getMouseIcon() {
		return mouseIcon;
	}

	public static void setMouseIcon(BufferedImage mouseIcon) {
		Global.mouseIcon = mouseIcon;
	}

	public static boolean isPaintMouse() {
		return paintMouse;
	}

	public static void setPaintMouse(boolean paintMouse) {
		Global.paintMouse = paintMouse;
	}

	public static boolean isReadyToGetColour() {
		return readyToGetColour;
	}

	public static void setReadyToGetColour(boolean readyToGetColour) {
		Global.readyToGetColour = readyToGetColour;
		listen.update();
	}

	public static Listener getListen() {
		return listen;
	}

	public static void setListen(Listener listen) {
		Global.listen = listen;
	}

	public static int getMainGUIx() {
		return mainGUIx;
	}

	public static int getMainGUIy() {
		return mainGUIy;
	}

	public static int getRs_panex() {
		return rs_panex;
	}

	public static int getRs_paney() {
		return rs_paney;
	}

	public static void setMainGUIx(int mainGUIx) {
		Global.mainGUIx = mainGUIx;
	}

	public static void setMainGUIy(int mainGUIy) {
		Global.mainGUIy = mainGUIy;
	}

	public static void setRs_panex(int rs_panex) {
		Global.rs_panex = rs_panex;
	}

	public static void setRs_paney(int rs_paney) {
		Global.rs_paney = rs_paney;
	}

	public static Rectangle getScreenArea() {
		return screenArea;
	}

	public static Rectangle getPlayArea() {
		return playArea;
	}

	public static Rectangle getMinimapArea() {
		return minimapArea;
	}

	public static Rectangle getTabArea() {
		return tabArea;
	}

	public static Rectangle getChatArea() {
		return chatArea;
	}

	public static void setScreenArea(Rectangle screenArea) {
		Global.screenArea = screenArea;
	}

	public static void setPlayArea(Rectangle playArea) {
		Global.playArea = playArea;
	}

	public static void setMinimapArea(Rectangle minimapArea) {
		Global.minimapArea = minimapArea;
	}

	public static void setTabArea(Rectangle tabArea) {
		Global.tabArea = tabArea;
	}

	public static void setChatArea(Rectangle chatArea) {
		Global.chatArea = chatArea;
	}

	public static Random getRandom() {
		return random;
	}

	public static void setRandom(Random random) {
		Global.random = random;
	}
}
